//
//  WebBgView.m
//  DGG_XDAPP
//
//  Created by apple on 16/12/1.
//  Copyright © 2016年 dgg. All rights reserved.
//

#import "WebBgView.h"
#import "UIView+Extension.h"



@implementation WebBgView

+(instancetype)loadNibWithTitle:(NSString *)title isShowNavBar:(BOOL)isShowNavBar tapBlock:(void(^)(void))tapBlock popBlock:(void(^)(void))popBlock subView:(UIView *)subView
{
    WebBgView * view = [[NSBundle mainBundle] loadNibNamed:kDLUIKitXIBName(@"WebBgView") owner:self options:nil][0];
    view.frame =subView.bounds;
    view.navBgView.backgroundColor = kNavColor;
    if (isShowNavBar) {
        view.navHeight.constant = 64.0f;
        view.titleLab.text = title;
        view.popBlock = popBlock;
        
        
    }else
    {
          view.navHeight.constant = 0;
    }
    __weak typeof (view) weakView =view;
    [view.bgView addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
        if (tapBlock) {
            tapBlock();
        }
        [weakView removeFromSuperview];
    }];
    
    [subView addSubview:view];
    return view;
}
- (IBAction)backBtnClick:(id)sender {
    if (self.popBlock) {
        [self removeFromSuperview];
        self.popBlock();
    }
}
@end
